﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using ScrumTable.Common;
using ScrumTable.DL.Data.Common;
using ScrumTable.DL.Data.Generic.Services;

#endregion

namespace ScrumTable.DL.Data.Generic.Test.Mocks
{
    /// <summary>
    /// This is the test class for GenericDataContextBase class.
    /// </summary>
    public class GenericDataContextStub : GenericDataContextBase
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private readonly IDataSaver _dataSaver;
        private readonly IDataLoader _dataLoader;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the internal data saver instance.
        /// </summary>
        public IDataSaver DataSaverInternal
        {
            get { return _dataSaver; }
        }

        /// <summary>
        /// Gets the internal data loader instance.
        /// </summary>
        internal protected override IDataLoader DataLoader
        {
            get { return _dataLoader; }
        }

        /// <summary>
        /// Gets the internal data saver instance.
        /// </summary>
        internal protected override IDataSaver DataSaver
        {
            get { return _dataSaver; }
        }

        /// <summary>
        /// Gets the data save manager factory which is used in conjunction
        /// with the connect procedure.
        /// </summary>
        internal protected override IDataSaveManagerFactory DataSaveManagerFactory
        {
            get { return new DataSaveManagerFactoryMock(); }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new GenericDataContextStub instance.
        /// </summary>
        internal GenericDataContextStub(IDataLoader loader, IDataSaver saver, IDataContextInfo driverInfo)
            : base(driverInfo)
        {
            PreCondition.AssertNotNull(loader, "loader");
            PreCondition.AssertNotNull(saver, "saver");

            _dataLoader = loader;
            _dataSaver = saver;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates the new data connection instance which is used to connect to the
        /// underlying data storage.
        /// </summary>
        /// <returns>Returns the newly created instance.</returns>
        protected override DataConnectionBase CreateDataConnection()
        {
            return new GenericDataConnectionStub(this);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
